package meiyunting.shiwuzhaoling.repository;

import meiyunting.shiwuzhaoling.model.Claim;
import meiyunting.shiwuzhaoling.model.Item;
import meiyunting.shiwuzhaoling.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ClaimRepository extends JpaRepository<Claim, Long> {
    List<Claim> findByItem(Item item);
    List<Claim> findByClaimer(User claimer);
    boolean existsByItemAndClaimer(Item item, User claimer);
    
    /**
     * 根据认领者ID查询
     */
    @Query("SELECT c FROM Claim c WHERE c.claimer.id = :claimerId")
    List<Claim> findByClaimerId(@Param("claimerId") Long claimerId);
} 